package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ReportDataMapper;
import com.ruoyi.system.service.IReportDataService;

/**
 * 报表数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-23
 */
@Service
public class ReportDataServiceImpl implements IReportDataService 
{
    @Autowired
    private ReportDataMapper reportDataMapper;

    /**
     * 查询销售明细报表数据
     * 
     * @param params 查询参数
     * @return 报表数据
     */
    @Override
    public List<Map<String, Object>> selectSaleDetailReportData(Map<String, Object> params)
    {
        params.put("type", 1);
        return reportDataMapper.selectSaleDetailReportData(params);
    }

    /**
     * 查询销售汇总报表数据
     * 
     * @param params 查询参数
     * @return 报表数据
     */
    @Override
    public List<Map<String, Object>> selectSaleSummaryReportData(Map<String, Object> params)
    {
        params.put("type", 1);
        return reportDataMapper.selectSaleSummaryReportData(params);
    }

    /**
     * 查询采购明细报表数据
     * 
     * @param params 查询参数
     * @return 报表数据
     */
    @Override
    public List<Map<String, Object>> selectPurchDetailReportData(Map<String, Object> params)
    {
        // 设置type为2表示采购
        params.put("type", 2);
        return reportDataMapper.selectSaleDetailReportData(params);
    }

    /**
     * 查询采购汇总报表数据
     * 
     * @param params 查询参数
     * @return 报表数据
     */
    @Override
    public List<Map<String, Object>> selectPurchSummaryReportData(Map<String, Object> params)
    {
        // 设置type为2表示采购
        params.put("type", 2);
        return reportDataMapper.selectSaleSummaryReportData(params);
    }

    /**
     * 根据报表编码和查询参数查询报表数据
     * 
     * @param reportCode 报表编码
     * @param params 查询参数
     * @return 报表数据
     */
    @Override
    public List<Map<String, Object>> selectReportData(String reportCode, Map<String, Object> params)
    {
        if ("sale_detail".equals(reportCode))
        {
            return selectSaleDetailReportData(params);
        }
        else if ("sale_summary".equals(reportCode))
        {
            return selectSaleSummaryReportData(params);
        }
        else if ("purch_detail".equals(reportCode))
        {
            return selectPurchDetailReportData(params);
        }
        else if ("purch_summary".equals(reportCode))
        {
            return selectPurchSummaryReportData(params);
        }
        return null;
    }
}
